#include "event_object.hh"

namespace kratos { namespace corelib {

EventObject::EventObject()
: eventID_(0), sender_(0), receiver_(0), timerID_(INVALID_TIMER_ID), cancelled_(false),
    timerQueue_(nullptr), fired_(false), period_(false) {
}

EventObject::~EventObject() {
    eventID_ = 0;
    sender_ = 0;
    receiver_ = 0;
    timerID_ = INVALID_TIMER_ID;
    cancelled_ = false;
    timerQueue_ = nullptr;
    fired_ = false;
    period_ = false;
}

void EventObject::setEventID(EventID eventID) {
    eventID_ = eventID;
}

EventID EventObject::getEventID() const {
    return eventID_;
}

void EventObject::setSender(std::uint64_t sender) {
    sender_ = sender;
}

void EventObject::setReceiver(std::uint64_t receiver) {
    receiver_ = receiver;
}

std::uint64_t EventObject::getSender() const {
    return sender_;
}

std::uint64_t EventObject::getReceiver() const {
    return receiver_;
}

void EventObject::cancel() {
    cancelled_ = true;
    if (timerID_ && timerQueue_) {
        timerQueue_->cancel(timerID_);
    }
}

bool EventObject::isCancelled() const {
    return cancelled_;
}

void EventObject::setTimerQueue(TimerQueue * timerQueue) {
    timerQueue_ = timerQueue;
}

TimerQueue * EventObject::getTimerQueue() const {
    return timerQueue_;
}

void EventObject::setTimerID(TimerID timerID) {
    timerID_ = timerID;
}

TimerID EventObject::getTimerID() {
    return timerID_;
}

void EventObject::fire() {
    fired_ = true;
}

bool EventObject::isFired() {
    return fired_;
}

void EventObject::setPeriod() {
    period_ = true;
}

bool EventObject::isPeriod() {
    return period_;
}

}}
